package LeetCode;

import java.util.Arrays;

public class LC_274_HIndex {

    public static void main(String[] args) {

    }

    static class Solution {
        public int hIndex(int[] citations) {
            Arrays.sort(citations);
            int result = 0;
            for (int i = 0; i < citations.length; i++) {
                int smaller = Math.min(citations[i], citations.length - i);
                result = Math.max(result, smaller);
            }
            return result;
        }

    }
}